{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Objective : 12. Data Transformation using Map, Apply & GroupBy\n",
    "<hr>\n",
    "\n",
    "1. Transforming Series using Map\n",
    "2. Transforming across multiple Series using apply\n",
    "3. GroupBy - Splitting, Applying & Combine\n",
    "\n",
    "<hr>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "hr_data = pd.read_csv('../Data/HR_comma_sep.csv.txt')\n",
    "hr_data.rename(columns={'sales':'department'}, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Transforming Series using Map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>department</th>\n",
       "      <th>salary</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.38</td>\n",
       "      <td>0.53</td>\n",
       "      <td>2</td>\n",
       "      <td>157</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.80</td>\n",
       "      <td>0.86</td>\n",
       "      <td>5</td>\n",
       "      <td>262</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.11</td>\n",
       "      <td>0.88</td>\n",
       "      <td>7</td>\n",
       "      <td>272</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.72</td>\n",
       "      <td>0.87</td>\n",
       "      <td>5</td>\n",
       "      <td>223</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.37</td>\n",
       "      <td>0.52</td>\n",
       "      <td>2</td>\n",
       "      <td>159</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   satisfaction_level  last_evaluation  number_project  average_montly_hours  \\\n",
       "0                0.38             0.53               2                   157   \n",
       "1                0.80             0.86               5                   262   \n",
       "2                0.11             0.88               7                   272   \n",
       "3                0.72             0.87               5                   223   \n",
       "4                0.37             0.52               2                   159   \n",
       "\n",
       "   time_spend_company  Work_accident  left  promotion_last_5years department  \\\n",
       "0                   3              0     1                      0      sales   \n",
       "1                   6              0     1                      0      sales   \n",
       "2                   4              0     1                      0      sales   \n",
       "3                   5              0     1                      0      sales   \n",
       "4                   3              0     1                      0      sales   \n",
       "\n",
       "   salary  \n",
       "0     low  \n",
       "1  medium  \n",
       "2  medium  \n",
       "3     low  \n",
       "4     low  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hr_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* map for transforming left column with some categorical information"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "hr_data['left_categorical'] = hr_data.left.map({1:'True',0:'False'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>department</th>\n",
       "      <th>salary</th>\n",
       "      <th>left_categorical</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.38</td>\n",
       "      <td>0.53</td>\n",
       "      <td>2</td>\n",
       "      <td>157</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.80</td>\n",
       "      <td>0.86</td>\n",
       "      <td>5</td>\n",
       "      <td>262</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>medium</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.11</td>\n",
       "      <td>0.88</td>\n",
       "      <td>7</td>\n",
       "      <td>272</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>medium</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.72</td>\n",
       "      <td>0.87</td>\n",
       "      <td>5</td>\n",
       "      <td>223</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.37</td>\n",
       "      <td>0.52</td>\n",
       "      <td>2</td>\n",
       "      <td>159</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   satisfaction_level  last_evaluation  number_project  average_montly_hours  \\\n",
       "0                0.38             0.53               2                   157   \n",
       "1                0.80             0.86               5                   262   \n",
       "2                0.11             0.88               7                   272   \n",
       "3                0.72             0.87               5                   223   \n",
       "4                0.37             0.52               2                   159   \n",
       "\n",
       "   time_spend_company  Work_accident  left  promotion_last_5years department  \\\n",
       "0                   3              0     1                      0      sales   \n",
       "1                   6              0     1                      0      sales   \n",
       "2                   4              0     1                      0      sales   \n",
       "3                   5              0     1                      0      sales   \n",
       "4                   3              0     1                      0      sales   \n",
       "\n",
       "   salary left_categorical  \n",
       "0     low             True  \n",
       "1  medium             True  \n",
       "2  medium             True  \n",
       "3     low             True  \n",
       "4     low             True  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hr_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Transforming data across multiple Series\n",
    "1. If satisfaction_level > .9, increase number_project by 1\n",
    "2. Multiple columns can't be dealt with map, we need apply for that"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def increase_proj(r):\n",
    "    if r.satisfaction_level > .9:\n",
    "        return r.number_project + 1\n",
    "    else:\n",
    "        return r.number_project\n",
    "\n",
    "hr_data['new_number_project'] = hr_data.apply(increase_proj, axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Filtering all the folks for which this happened"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>department</th>\n",
       "      <th>salary</th>\n",
       "      <th>left_categorical</th>\n",
       "      <th>new_number_project</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.85</td>\n",
       "      <td>5</td>\n",
       "      <td>259</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "      <td>True</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>106</th>\n",
       "      <td>0.91</td>\n",
       "      <td>1.00</td>\n",
       "      <td>4</td>\n",
       "      <td>257</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>accounting</td>\n",
       "      <td>medium</td>\n",
       "      <td>True</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>191</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.87</td>\n",
       "      <td>4</td>\n",
       "      <td>226</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>technical</td>\n",
       "      <td>medium</td>\n",
       "      <td>True</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>231</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.99</td>\n",
       "      <td>5</td>\n",
       "      <td>255</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>sales</td>\n",
       "      <td>low</td>\n",
       "      <td>True</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>352</th>\n",
       "      <td>0.91</td>\n",
       "      <td>0.91</td>\n",
       "      <td>4</td>\n",
       "      <td>262</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>support</td>\n",
       "      <td>low</td>\n",
       "      <td>True</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     satisfaction_level  last_evaluation  number_project  \\\n",
       "7                  0.92             0.85               5   \n",
       "106                0.91             1.00               4   \n",
       "191                0.92             0.87               4   \n",
       "231                0.92             0.99               5   \n",
       "352                0.91             0.91               4   \n",
       "\n",
       "     average_montly_hours  time_spend_company  Work_accident  left  \\\n",
       "7                     259                   5              0     1   \n",
       "106                   257                   5              0     1   \n",
       "191                   226                   6              1     1   \n",
       "231                   255                   6              0     1   \n",
       "352                   262                   6              0     1   \n",
       "\n",
       "     promotion_last_5years  department  salary left_categorical  \\\n",
       "7                        0       sales     low             True   \n",
       "106                      0  accounting  medium             True   \n",
       "191                      0   technical  medium             True   \n",
       "231                      0       sales     low             True   \n",
       "352                      0     support     low             True   \n",
       "\n",
       "     new_number_project  \n",
       "7                     6  \n",
       "106                   5  \n",
       "191                   5  \n",
       "231                   6  \n",
       "352                   5  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hr_data[hr_data.number_project != hr_data.new_number_project].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. GroupBy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped = hr_data.groupby(['department'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Compute first & last of group values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>salary</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>department</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>IT</th>\n",
       "      <td>0.11</td>\n",
       "      <td>0.93</td>\n",
       "      <td>7</td>\n",
       "      <td>308</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RandD</th>\n",
       "      <td>0.12</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3</td>\n",
       "      <td>278</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>accounting</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.46</td>\n",
       "      <td>2</td>\n",
       "      <td>128</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hr</th>\n",
       "      <td>0.45</td>\n",
       "      <td>0.57</td>\n",
       "      <td>2</td>\n",
       "      <td>134</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>management</th>\n",
       "      <td>0.85</td>\n",
       "      <td>0.91</td>\n",
       "      <td>5</td>\n",
       "      <td>226</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>marketing</th>\n",
       "      <td>0.40</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2</td>\n",
       "      <td>137</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>product_mng</th>\n",
       "      <td>0.43</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2</td>\n",
       "      <td>153</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sales</th>\n",
       "      <td>0.38</td>\n",
       "      <td>0.53</td>\n",
       "      <td>2</td>\n",
       "      <td>157</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>support</th>\n",
       "      <td>0.40</td>\n",
       "      <td>0.55</td>\n",
       "      <td>2</td>\n",
       "      <td>147</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>technical</th>\n",
       "      <td>0.10</td>\n",
       "      <td>0.94</td>\n",
       "      <td>6</td>\n",
       "      <td>255</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             satisfaction_level  last_evaluation  number_project  \\\n",
       "department                                                         \n",
       "IT                         0.11             0.93               7   \n",
       "RandD                      0.12             1.00               3   \n",
       "accounting                 0.41             0.46               2   \n",
       "hr                         0.45             0.57               2   \n",
       "management                 0.85             0.91               5   \n",
       "marketing                  0.40             0.54               2   \n",
       "product_mng                0.43             0.54               2   \n",
       "sales                      0.38             0.53               2   \n",
       "support                    0.40             0.55               2   \n",
       "technical                  0.10             0.94               6   \n",
       "\n",
       "             average_montly_hours  time_spend_company  Work_accident  left  \\\n",
       "department                                                                   \n",
       "IT                            308                   4              0     1   \n",
       "RandD                         278                   4              0     1   \n",
       "accounting                    128                   3              0     1   \n",
       "hr                            134                   3              0     1   \n",
       "management                    226                   5              0     1   \n",
       "marketing                     137                   3              0     1   \n",
       "product_mng                   153                   3              0     1   \n",
       "sales                         157                   3              0     1   \n",
       "support                       147                   3              0     1   \n",
       "technical                     255                   4              0     1   \n",
       "\n",
       "             promotion_last_5years  salary  \n",
       "department                                  \n",
       "IT                               0  medium  \n",
       "RandD                            0  medium  \n",
       "accounting                       0     low  \n",
       "hr                               0     low  \n",
       "management                       0  medium  \n",
       "marketing                        0  medium  \n",
       "product_mng                      0  medium  \n",
       "sales                            0     low  \n",
       "support                          0     low  \n",
       "technical                        0     low  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.first()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>salary</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>department</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>IT</th>\n",
       "      <td>0.90</td>\n",
       "      <td>0.92</td>\n",
       "      <td>4</td>\n",
       "      <td>271</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RandD</th>\n",
       "      <td>0.81</td>\n",
       "      <td>0.92</td>\n",
       "      <td>5</td>\n",
       "      <td>239</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>accounting</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2</td>\n",
       "      <td>153</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hr</th>\n",
       "      <td>0.40</td>\n",
       "      <td>0.47</td>\n",
       "      <td>2</td>\n",
       "      <td>144</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>management</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.57</td>\n",
       "      <td>2</td>\n",
       "      <td>147</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>marketing</th>\n",
       "      <td>0.44</td>\n",
       "      <td>0.52</td>\n",
       "      <td>2</td>\n",
       "      <td>149</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>product_mng</th>\n",
       "      <td>0.46</td>\n",
       "      <td>0.55</td>\n",
       "      <td>2</td>\n",
       "      <td>147</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sales</th>\n",
       "      <td>0.39</td>\n",
       "      <td>0.45</td>\n",
       "      <td>2</td>\n",
       "      <td>140</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>support</th>\n",
       "      <td>0.37</td>\n",
       "      <td>0.52</td>\n",
       "      <td>2</td>\n",
       "      <td>158</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>technical</th>\n",
       "      <td>0.43</td>\n",
       "      <td>0.57</td>\n",
       "      <td>2</td>\n",
       "      <td>159</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             satisfaction_level  last_evaluation  number_project  \\\n",
       "department                                                         \n",
       "IT                         0.90             0.92               4   \n",
       "RandD                      0.81             0.92               5   \n",
       "accounting                 0.36             0.54               2   \n",
       "hr                         0.40             0.47               2   \n",
       "management                 0.42             0.57               2   \n",
       "marketing                  0.44             0.52               2   \n",
       "product_mng                0.46             0.55               2   \n",
       "sales                      0.39             0.45               2   \n",
       "support                    0.37             0.52               2   \n",
       "technical                  0.43             0.57               2   \n",
       "\n",
       "             average_montly_hours  time_spend_company  Work_accident  left  \\\n",
       "department                                                                   \n",
       "IT                            271                   5              0     1   \n",
       "RandD                         239                   5              0     1   \n",
       "accounting                    153                   3              0     1   \n",
       "hr                            144                   3              0     1   \n",
       "management                    147                   3              1     1   \n",
       "marketing                     149                   3              0     1   \n",
       "product_mng                   147                   3              0     1   \n",
       "sales                         140                   3              0     1   \n",
       "support                       158                   3              0     1   \n",
       "technical                     159                   3              1     1   \n",
       "\n",
       "             promotion_last_5years  salary  \n",
       "department                                  \n",
       "IT                               0  medium  \n",
       "RandD                            0  medium  \n",
       "accounting                       0  medium  \n",
       "hr                               0  medium  \n",
       "management                       0     low  \n",
       "marketing                        0     low  \n",
       "product_mng                      0  medium  \n",
       "sales                            0  medium  \n",
       "support                          0     low  \n",
       "technical                        0     low  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.last()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>salary</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>department</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>IT</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.56</td>\n",
       "      <td>2</td>\n",
       "      <td>132</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RandD</th>\n",
       "      <td>0.37</td>\n",
       "      <td>0.55</td>\n",
       "      <td>2</td>\n",
       "      <td>127</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>accounting</th>\n",
       "      <td>0.09</td>\n",
       "      <td>0.62</td>\n",
       "      <td>6</td>\n",
       "      <td>294</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hr</th>\n",
       "      <td>0.45</td>\n",
       "      <td>0.55</td>\n",
       "      <td>2</td>\n",
       "      <td>140</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>management</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.48</td>\n",
       "      <td>2</td>\n",
       "      <td>129</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>marketing</th>\n",
       "      <td>0.11</td>\n",
       "      <td>0.77</td>\n",
       "      <td>6</td>\n",
       "      <td>291</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>product_mng</th>\n",
       "      <td>0.76</td>\n",
       "      <td>0.86</td>\n",
       "      <td>5</td>\n",
       "      <td>223</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sales</th>\n",
       "      <td>0.11</td>\n",
       "      <td>0.88</td>\n",
       "      <td>7</td>\n",
       "      <td>272</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>medium</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>support</th>\n",
       "      <td>0.40</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2</td>\n",
       "      <td>148</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>technical</th>\n",
       "      <td>0.45</td>\n",
       "      <td>0.50</td>\n",
       "      <td>2</td>\n",
       "      <td>126</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             satisfaction_level  last_evaluation  number_project  \\\n",
       "department                                                         \n",
       "IT                         0.36             0.56               2   \n",
       "RandD                      0.37             0.55               2   \n",
       "accounting                 0.09             0.62               6   \n",
       "hr                         0.45             0.55               2   \n",
       "management                 0.42             0.48               2   \n",
       "marketing                  0.11             0.77               6   \n",
       "product_mng                0.76             0.86               5   \n",
       "sales                      0.11             0.88               7   \n",
       "support                    0.40             0.54               2   \n",
       "technical                  0.45             0.50               2   \n",
       "\n",
       "             average_montly_hours  time_spend_company  Work_accident  left  \\\n",
       "department                                                                   \n",
       "IT                            132                   3              0     1   \n",
       "RandD                         127                   3              0     1   \n",
       "accounting                    294                   4              0     1   \n",
       "hr                            140                   3              0     1   \n",
       "management                    129                   3              0     1   \n",
       "marketing                     291                   4              0     1   \n",
       "product_mng                   223                   5              1     1   \n",
       "sales                         272                   4              0     1   \n",
       "support                       148                   3              0     1   \n",
       "technical                     126                   3              0     1   \n",
       "\n",
       "             promotion_last_5years  salary  \n",
       "department                                  \n",
       "IT                               0  medium  \n",
       "RandD                            0  medium  \n",
       "accounting                       0     low  \n",
       "hr                               0     low  \n",
       "management                       0     low  \n",
       "marketing                        0     low  \n",
       "product_mng                      0  medium  \n",
       "sales                            0  medium  \n",
       "support                          0     low  \n",
       "technical                        0     low  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.nth(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'IT': Int64Index([   61,    62,    63,    64,    65,    70,   138,   139,   140,\n",
       "               141,\n",
       "             ...\n",
       "             14808, 14809, 14810, 14815, 14929, 14930, 14931, 14932, 14933,\n",
       "             14938],\n",
       "            dtype='int64', length=1227),\n",
       " 'RandD': Int64Index([  301,   302,   303,   304,   305,   453,   454,   455,   456,\n",
       "               457,\n",
       "             ...\n",
       "             14816, 14817, 14818, 14819, 14820, 14939, 14940, 14941, 14942,\n",
       "             14943],\n",
       "            dtype='int64', length=787),\n",
       " 'accounting': Int64Index([   28,    29,    30,    79,   105,   106,   107,   155,   181,\n",
       "               182,\n",
       "             ...\n",
       "             14849, 14850, 14851, 14896, 14897, 14898, 14946, 14972, 14973,\n",
       "             14974],\n",
       "            dtype='int64', length=767),\n",
       " 'hr': Int64Index([   31,    32,    33,    34,   108,   109,   110,   111,   184,\n",
       "               185,\n",
       "             ...\n",
       "             14854, 14855, 14899, 14900, 14901, 14902, 14975, 14976, 14977,\n",
       "             14978],\n",
       "            dtype='int64', length=739),\n",
       " 'management': Int64Index([   60,    82,   137,   158,   213,   235,   290,   311,   366,\n",
       "               387,\n",
       "             ...\n",
       "             14598, 14653, 14674, 14729, 14750, 14805, 14826, 14873, 14928,\n",
       "             14949],\n",
       "            dtype='int64', length=630),\n",
       " 'marketing': Int64Index([   77,    83,    84,    85,   148,   149,   150,   151,   152,\n",
       "               153,\n",
       "             ...\n",
       "             14827, 14828, 14829, 14874, 14875, 14876, 14944, 14950, 14951,\n",
       "             14952],\n",
       "            dtype='int64', length=858),\n",
       " 'product_mng': Int64Index([   66,    67,    68,    69,    71,    72,    73,    74,    75,\n",
       "                76,\n",
       "             ...\n",
       "             14737, 14738, 14811, 14812, 14813, 14814, 14934, 14935, 14936,\n",
       "             14937],\n",
       "            dtype='int64', length=902),\n",
       " 'sales': Int64Index([    0,     1,     2,     3,     4,     5,     6,     7,     8,\n",
       "                 9,\n",
       "             ...\n",
       "             14962, 14963, 14964, 14965, 14966, 14967, 14968, 14969, 14970,\n",
       "             14971],\n",
       "            dtype='int64', length=4140),\n",
       " 'support': Int64Index([   46,    47,    48,    49,    50,    51,    52,    53,    54,\n",
       "                55,\n",
       "             ...\n",
       "             14947, 14990, 14991, 14992, 14993, 14994, 14995, 14996, 14997,\n",
       "             14998],\n",
       "            dtype='int64', length=2229),\n",
       " 'technical': Int64Index([   35,    36,    37,    38,    39,    40,    41,    42,    43,\n",
       "                44,\n",
       "             ...\n",
       "             14980, 14981, 14982, 14983, 14984, 14985, 14986, 14987, 14988,\n",
       "             14989],\n",
       "            dtype='int64', length=2720)}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.groups"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{('IT',\n",
       "  'high'): Int64Index([ 1281,  1359,  1437,  1515,  3192,  3193,  3194,  3195,  3200,\n",
       "              3270,  3504,  3799,  3802,  4260,  4264,  4269,  4720,  5097,\n",
       "              5098,  5557,  5558,  5559,  5560,  5561,  5634,  5712,  5790,\n",
       "              5865,  5943,  6024,  6093,  6547,  6550,  7009,  7011,  7012,\n",
       "              7087,  7474,  7544,  7845,  7846,  7847,  7848,  7849,  7998,\n",
       "              8076,  8154,  8229,  8307,  8308,  8309,  8314,  8385,  8772,\n",
       "              8917,  8919,  9375,  9835, 10213, 10593, 10671, 10672, 10673,\n",
       "             10678, 10747, 10749, 10980, 11268, 11601, 11700, 11707, 12804,\n",
       "             12882, 12883, 12884, 12889, 12958, 12960, 13191, 13479, 13812,\n",
       "             13911, 13918],\n",
       "            dtype='int64'),\n",
       " ('IT',\n",
       "  'low'): Int64Index([  138,   139,   140,   141,   142,   147,   214,   215,   216,\n",
       "               217,\n",
       "             ...\n",
       "             14731, 14732, 14733, 14734, 14806, 14807, 14808, 14809, 14810,\n",
       "             14815],\n",
       "            dtype='int64', length=609),\n",
       " ('IT',\n",
       "  'medium'): Int64Index([   61,    62,    63,    64,    65,    70,   294,   295,   300,\n",
       "               376,\n",
       "             ...\n",
       "             14511, 14587, 14663, 14739, 14929, 14930, 14931, 14932, 14933,\n",
       "             14938],\n",
       "            dtype='int64', length=535),\n",
       " ('RandD',\n",
       "  'high'): Int64Index([ 1827,  1905,  1983,  3201,  3202,  3203,  3657,  3658,  3659,\n",
       "              3660,  3661,  3735,  3813,  4044,  4729,  5185,  6025,  6026,\n",
       "              6027,  6028,  6177,  6255,  6330,  6408,  6558,  7018,  7476,\n",
       "              7477,  7552,  8009,  8315,  8316,  8317,  8318,  8773,  8774,\n",
       "              8775,  8776,  8777,  8850,  8928,  9382,  9384, 10300, 11659,\n",
       "             11661, 11662, 13870, 13872, 13873, 14941],\n",
       "            dtype='int64'),\n",
       " ('RandD',\n",
       "  'low'): Int64Index([  605,   833,   834,   835,   836,   837,   985,   986,   987,\n",
       "               988,\n",
       "             ...\n",
       "             13213, 13214, 13215, 13216, 13217, 13871, 13874, 13875, 14816,\n",
       "             14942],\n",
       "            dtype='int64', length=364),\n",
       " ('RandD',\n",
       "  'medium'): Int64Index([  301,   302,   303,   304,   305,   453,   454,   455,   456,\n",
       "               457,\n",
       "             ...\n",
       "             14666, 14667, 14668, 14817, 14818, 14819, 14820, 14939, 14940,\n",
       "             14943],\n",
       "            dtype='int64', length=372),\n",
       " ('accounting',\n",
       "  'high'): Int64Index([  384,  1632,  1710,  3234,  3235,  3236,  3387,  3540,  3664,\n",
       "              3768,  4124,  4228,  4684,  4686,  4734,  4762,  5190,  5524,\n",
       "              5525,  5526,  5982,  5983,  5984,  6060,  6488,  6564,  6592,\n",
       "              6795,  7510,  7888,  8349,  8350,  8351,  8502,  8580,  8655,\n",
       "              8780,  8883,  9084,  9340,  9613,  9614,  9799,  9801,  9843,\n",
       "              9844,  9877,  9920,  9921,  9996,  9997, 10072, 10073, 10334,\n",
       "             10636, 10637, 10638, 10866, 10944, 11101, 11214, 11971, 11972,\n",
       "             12384, 12847, 12848, 12849, 13077, 13155, 13312, 13425, 14182,\n",
       "             14183, 14595],\n",
       "            dtype='int64'),\n",
       " ('accounting',\n",
       "  'low'): Int64Index([   28,    29,    30,    79,   155,   224,   225,   232,   410,\n",
       "               486,\n",
       "             ...\n",
       "             14621, 14697, 14698, 14699, 14773, 14774, 14775, 14849, 14850,\n",
       "             14851],\n",
       "            dtype='int64', length=358),\n",
       " ('accounting',\n",
       "  'medium'): Int64Index([  105,   106,   107,   181,   182,   183,   258,   259,   260,\n",
       "               308,\n",
       "             ...\n",
       "             14741, 14747, 14823, 14896, 14897, 14898, 14946, 14972, 14973,\n",
       "             14974],\n",
       "            dtype='int64', length=335),\n",
       " ('hr',\n",
       "  'high'): Int64Index([  111,  1788,  1866,  3237,  3238,  3465,  3618,  3696,  3772,\n",
       "              4233,  4687,  4690,  5219,  5527,  5528,  5985,  5986,  5987,\n",
       "              5988,  6138,  6216,  6594,  7054,  7057,  8352,  8353,  8733,\n",
       "              8811,  8812,  8887,  9343,  9802,  9805, 10338, 10639, 10640,\n",
       "             10641, 10642, 12111, 12850, 12851, 12852, 12853, 14322, 14902],\n",
       "            dtype='int64'),\n",
       " ('hr',\n",
       "  'low'): Int64Index([   31,    32,    33,    34,   226,   227,   228,   565,   566,\n",
       "               641,\n",
       "             ...\n",
       "             14245, 14437, 14438, 14439, 14776, 14777, 14852, 14853, 14854,\n",
       "             14855],\n",
       "            dtype='int64', length=335),\n",
       " ('hr',\n",
       "  'medium'): Int64Index([  108,   109,   110,   184,   185,   186,   187,   261,   262,\n",
       "               263,\n",
       "             ...\n",
       "             14744, 14778, 14779, 14899, 14900, 14901, 14975, 14976, 14977,\n",
       "             14978],\n",
       "            dtype='int64', length=359),\n",
       " ('management',\n",
       "  'high'): Int64Index([ 1203,  2217,  3114,  3363,  3667,  4127,  4509,  5096,  5325,\n",
       "              5556,\n",
       "             ...\n",
       "             14148, 14149, 14150, 14151, 14186, 14204, 14205, 14206, 14207,\n",
       "             14208],\n",
       "            dtype='int64', length=225),\n",
       " ('management',\n",
       "  'low'): Int64Index([   82,   137,   158,   213,   235,   290,   366,   442,   463,\n",
       "               518,\n",
       "             ...\n",
       "             14446, 14501, 14577, 14653, 14674, 14729, 14805, 14873, 14928,\n",
       "             14949],\n",
       "            dtype='int64', length=180),\n",
       " ('management',\n",
       "  'medium'): Int64Index([   60,   311,   387,   539,   615,   691,   767,   843,   919,\n",
       "               974,\n",
       "             ...\n",
       "             13727, 13881, 14005, 14089, 14157, 14271, 14522, 14598, 14750,\n",
       "             14826],\n",
       "            dtype='int64', length=225),\n",
       " ('marketing',\n",
       "  'high'): Int64Index([  306,   540,   618,  2295,  3289,  3662,  3668,  3891,  4122,\n",
       "              4128,  4129,  4130,  4434,  4587,  4588,  4732,  5194,  5655,\n",
       "              6486,  6492,  6493,  6562,  6953,  6954,  6955,  7023,  7029,\n",
       "              7107,  7260,  7480,  7488,  7942,  8013,  8404,  8474,  8482,\n",
       "              8778,  9006,  9393,  9471,  9549,  9612,  9624,  9702,  9703,\n",
       "              9842,  9919,  9995, 10071, 10312, 11099, 11105, 11106, 11107,\n",
       "             11484, 11608, 11665, 11673, 11796, 11949, 11970, 11998, 12306,\n",
       "             12540, 12618, 13310, 13316, 13317, 13318, 13695, 13819, 13876,\n",
       "             13884, 14007, 14160, 14181, 14209, 14517, 14751, 14829],\n",
       "            dtype='int64'),\n",
       " ('marketing',\n",
       "  'low'): Int64Index([   83,    84,    85,   148,   149,   150,   151,   152,   153,\n",
       "               159,\n",
       "             ...\n",
       "             14524, 14525, 14601, 14752, 14874, 14875, 14876, 14950, 14951,\n",
       "             14952],\n",
       "            dtype='int64', length=402),\n",
       " ('marketing',\n",
       "  'medium'): Int64Index([   77,   382,   388,   389,   458,   464,   465,   466,   534,\n",
       "               542,\n",
       "             ...\n",
       "             14669, 14675, 14676, 14677, 14745, 14753, 14821, 14827, 14828,\n",
       "             14944],\n",
       "            dtype='int64', length=376),\n",
       " ('product_mng',\n",
       "  'high'): Int64Index([   72,  1593,  1671,  1749,  3196,  3197,  3198,  3199,  3348,\n",
       "              3426,  3579,  3804,  4267,  4725,  5562,  5563,  6021,  6022,\n",
       "              6023,  6097,  6099,  6553,  7015,  7548,  7850,  7851,  7852,\n",
       "              7853,  8310,  8311,  8312,  8313,  8463,  8541,  8619,  8694,\n",
       "              9379,  9840, 10674, 10675, 10676, 10677, 10827, 10905, 11175,\n",
       "             11253, 11264, 11445, 11523, 11704, 11835, 11988, 12072, 12885,\n",
       "             12886, 12887, 12888, 13038, 13116, 13386, 13464, 13475, 13656,\n",
       "             13734, 13915, 14046, 14199, 14283],\n",
       "            dtype='int64'),\n",
       " ('product_mng',\n",
       "  'low'): Int64Index([   73,   143,   144,   145,   146,   219,   220,   221,   222,\n",
       "               448,\n",
       "             ...\n",
       "             14659, 14660, 14735, 14736, 14737, 14738, 14811, 14812, 14813,\n",
       "             14814],\n",
       "            dtype='int64', length=451),\n",
       " ('product_mng',\n",
       "  'medium'): Int64Index([   66,    67,    68,    69,    71,    74,    75,    76,   296,\n",
       "               297,\n",
       "             ...\n",
       "             14583, 14584, 14585, 14586, 14661, 14662, 14934, 14935, 14936,\n",
       "             14937],\n",
       "            dtype='int64', length=383),\n",
       " ('sales',\n",
       "  'high'): Int64Index([  696,   774,   852,   930,  1008,  1086,  1164,  1242,  1320,\n",
       "              1398,\n",
       "             ...\n",
       "             13503, 13581, 13620, 13888, 13890, 13929, 13940, 13944, 13948,\n",
       "             14121],\n",
       "            dtype='int64', length=269),\n",
       " ('sales',\n",
       "  'low'): Int64Index([    0,     3,     4,     5,     6,     7,     8,     9,    10,\n",
       "                11,\n",
       "             ...\n",
       "             14958, 14959, 14960, 14961, 14962, 14963, 14964, 14965, 14966,\n",
       "             14967],\n",
       "            dtype='int64', length=2099),\n",
       " ('sales',\n",
       "  'medium'): Int64Index([    1,     2,    99,   100,   101,   102,   103,   104,   177,\n",
       "               178,\n",
       "             ...\n",
       "             14891, 14892, 14893, 14894, 14895, 14945, 14968, 14969, 14970,\n",
       "             14971],\n",
       "            dtype='int64', length=1772),\n",
       " ('support',\n",
       "  'high'): Int64Index([  657,   735,   813,   891,   969,  2139,  2334,  2412,  2490,\n",
       "              2568,\n",
       "             ...\n",
       "             12949, 13018, 13269, 13313, 13446, 13450, 13542, 13879, 14085,\n",
       "             14868],\n",
       "            dtype='int64', length=141),\n",
       " ('support',\n",
       "  'low'): Int64Index([   46,    47,    48,    49,    50,    51,    52,    53,    54,\n",
       "                55,\n",
       "             ...\n",
       "             14947, 14990, 14991, 14992, 14993, 14994, 14995, 14996, 14997,\n",
       "             14998],\n",
       "            dtype='int64', length=1146),\n",
       " ('support',\n",
       "  'medium'): Int64Index([  309,   428,   461,   504,   505,   506,   537,   581,   582,\n",
       "               583,\n",
       "             ...\n",
       "             14748, 14792, 14793, 14794, 14795, 14824, 14867, 14870, 14871,\n",
       "             14872],\n",
       "            dtype='int64', length=942),\n",
       " ('technical',\n",
       "  'high'): Int64Index([  189,   267,   345,   423,   462,   501,   579,  1047,  1125,\n",
       "              1944,\n",
       "             ...\n",
       "             13851, 13906, 14400, 14478, 14556, 14634, 14673, 14712, 14790,\n",
       "             14980],\n",
       "            dtype='int64', length=201),\n",
       " ('technical',\n",
       "  'low'): Int64Index([   35,    36,    37,    38,    39,    40,    41,    42,    43,\n",
       "                44,\n",
       "             ...\n",
       "             14913, 14925, 14926, 14927, 14948, 14981, 14986, 14987, 14988,\n",
       "             14989],\n",
       "            dtype='int64', length=1372),\n",
       " ('technical',\n",
       "  'medium'): Int64Index([  113,   114,   115,   116,   188,   191,   192,   193,   194,\n",
       "               265,\n",
       "             ...\n",
       "             14866, 14904, 14905, 14906, 14907, 14979, 14982, 14983, 14984,\n",
       "             14985],\n",
       "            dtype='int64', length=1147)}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hr_data.groupby(['department','salary']).groups"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Selecting a group"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped = hr_data.groupby(['department','salary'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "      <th>department</th>\n",
       "      <th>salary</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>0.10</td>\n",
       "      <td>0.94</td>\n",
       "      <td>6</td>\n",
       "      <td>255</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>technical</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>0.38</td>\n",
       "      <td>0.46</td>\n",
       "      <td>2</td>\n",
       "      <td>137</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>technical</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>0.45</td>\n",
       "      <td>0.50</td>\n",
       "      <td>2</td>\n",
       "      <td>126</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>technical</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>0.11</td>\n",
       "      <td>0.89</td>\n",
       "      <td>6</td>\n",
       "      <td>306</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>technical</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2</td>\n",
       "      <td>152</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>technical</td>\n",
       "      <td>low</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    satisfaction_level  last_evaluation  number_project  average_montly_hours  \\\n",
       "35                0.10             0.94               6                   255   \n",
       "36                0.38             0.46               2                   137   \n",
       "37                0.45             0.50               2                   126   \n",
       "38                0.11             0.89               6                   306   \n",
       "39                0.41             0.54               2                   152   \n",
       "\n",
       "    time_spend_company  Work_accident  left  promotion_last_5years department  \\\n",
       "35                   4              0     1                      0  technical   \n",
       "36                   3              0     1                      0  technical   \n",
       "37                   3              0     1                      0  technical   \n",
       "38                   4              0     1                      0  technical   \n",
       "39                   3              0     1                      0  technical   \n",
       "\n",
       "   salary  \n",
       "35    low  \n",
       "36    low  \n",
       "37    low  \n",
       "38    low  \n",
       "39    low  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.get_group(('technical','low')).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Aggregation \n",
    "* Once the GroupBy object has been created, several methods are available to perform a computation on the grouped data. \n",
    "* These operations are similar to the aggregating API, window functions API, and resample API."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "department   salary\n",
       "IT           high      3.867470\n",
       "             low       3.794745\n",
       "             medium    3.833645\n",
       "RandD        high      3.764706\n",
       "             low       3.804945\n",
       "             medium    3.913978\n",
       "accounting   high      3.905405\n",
       "             low       3.801676\n",
       "             medium    3.832836\n",
       "hr           high      3.888889\n",
       "             low       3.692537\n",
       "             medium    3.590529\n",
       "management   high      3.777778\n",
       "             low       3.777778\n",
       "             medium    4.008889\n",
       "marketing    high      3.425000\n",
       "             low       3.751244\n",
       "             medium    3.675532\n",
       "product_mng  high      3.705882\n",
       "             low       3.824834\n",
       "             medium    3.804178\n",
       "sales        high      3.858736\n",
       "             low       3.757980\n",
       "             medium    3.785553\n",
       "support      high      3.794326\n",
       "             low       3.787086\n",
       "             medium    3.825902\n",
       "technical    high      3.651741\n",
       "             low       3.910350\n",
       "             medium    3.878814\n",
       "Name: number_project, dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.number_project.aggregate(np.mean)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"2\" halign=\"left\">satisfaction_level</th>\n",
       "      <th colspan=\"2\" halign=\"left\">last_evaluation</th>\n",
       "      <th colspan=\"2\" halign=\"left\">number_project</th>\n",
       "      <th colspan=\"2\" halign=\"left\">average_montly_hours</th>\n",
       "      <th colspan=\"2\" halign=\"left\">time_spend_company</th>\n",
       "      <th colspan=\"2\" halign=\"left\">Work_accident</th>\n",
       "      <th colspan=\"2\" halign=\"left\">left</th>\n",
       "      <th colspan=\"2\" halign=\"left\">promotion_last_5years</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "      <th>mean</th>\n",
       "      <th>amax</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>department</th>\n",
       "      <th>salary</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">IT</th>\n",
       "      <th>high</th>\n",
       "      <td>0.638193</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.716627</td>\n",
       "      <td>0.99</td>\n",
       "      <td>3.867470</td>\n",
       "      <td>6</td>\n",
       "      <td>194.927711</td>\n",
       "      <td>275</td>\n",
       "      <td>3.072289</td>\n",
       "      <td>6</td>\n",
       "      <td>0.048193</td>\n",
       "      <td>1</td>\n",
       "      <td>0.048193</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.610099</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.715665</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.794745</td>\n",
       "      <td>7</td>\n",
       "      <td>201.382594</td>\n",
       "      <td>308</td>\n",
       "      <td>3.438424</td>\n",
       "      <td>10</td>\n",
       "      <td>0.146141</td>\n",
       "      <td>1</td>\n",
       "      <td>0.282430</td>\n",
       "      <td>1</td>\n",
       "      <td>0.003284</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.624187</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.718187</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.833645</td>\n",
       "      <td>7</td>\n",
       "      <td>204.295327</td>\n",
       "      <td>308</td>\n",
       "      <td>3.564486</td>\n",
       "      <td>10</td>\n",
       "      <td>0.132710</td>\n",
       "      <td>1</td>\n",
       "      <td>0.181308</td>\n",
       "      <td>1</td>\n",
       "      <td>0.001869</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">RandD</th>\n",
       "      <th>high</th>\n",
       "      <td>0.586667</td>\n",
       "      <td>0.97</td>\n",
       "      <td>0.700588</td>\n",
       "      <td>0.95</td>\n",
       "      <td>3.764706</td>\n",
       "      <td>6</td>\n",
       "      <td>199.745098</td>\n",
       "      <td>287</td>\n",
       "      <td>3.529412</td>\n",
       "      <td>8</td>\n",
       "      <td>0.176471</td>\n",
       "      <td>1</td>\n",
       "      <td>0.078431</td>\n",
       "      <td>1</td>\n",
       "      <td>0.019608</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.623929</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.714176</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.804945</td>\n",
       "      <td>7</td>\n",
       "      <td>198.747253</td>\n",
       "      <td>308</td>\n",
       "      <td>3.381868</td>\n",
       "      <td>8</td>\n",
       "      <td>0.195055</td>\n",
       "      <td>1</td>\n",
       "      <td>0.151099</td>\n",
       "      <td>1</td>\n",
       "      <td>0.008242</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.620349</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.711694</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.913978</td>\n",
       "      <td>7</td>\n",
       "      <td>202.954301</td>\n",
       "      <td>301</td>\n",
       "      <td>3.330645</td>\n",
       "      <td>6</td>\n",
       "      <td>0.145161</td>\n",
       "      <td>1</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>1</td>\n",
       "      <td>0.061828</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">accounting</th>\n",
       "      <th>high</th>\n",
       "      <td>0.614054</td>\n",
       "      <td>0.97</td>\n",
       "      <td>0.724595</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.905405</td>\n",
       "      <td>6</td>\n",
       "      <td>205.905405</td>\n",
       "      <td>277</td>\n",
       "      <td>3.216216</td>\n",
       "      <td>8</td>\n",
       "      <td>0.202703</td>\n",
       "      <td>1</td>\n",
       "      <td>0.067568</td>\n",
       "      <td>1</td>\n",
       "      <td>0.081081</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.574162</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.713883</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.801676</td>\n",
       "      <td>7</td>\n",
       "      <td>199.899441</td>\n",
       "      <td>308</td>\n",
       "      <td>3.438547</td>\n",
       "      <td>10</td>\n",
       "      <td>0.111732</td>\n",
       "      <td>1</td>\n",
       "      <td>0.276536</td>\n",
       "      <td>1</td>\n",
       "      <td>0.005587</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.583642</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.720299</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.832836</td>\n",
       "      <td>7</td>\n",
       "      <td>201.465672</td>\n",
       "      <td>310</td>\n",
       "      <td>3.680597</td>\n",
       "      <td>10</td>\n",
       "      <td>0.122388</td>\n",
       "      <td>1</td>\n",
       "      <td>0.298507</td>\n",
       "      <td>1</td>\n",
       "      <td>0.017910</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">hr</th>\n",
       "      <th>high</th>\n",
       "      <td>0.673111</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.743778</td>\n",
       "      <td>0.99</td>\n",
       "      <td>3.888889</td>\n",
       "      <td>6</td>\n",
       "      <td>209.066667</td>\n",
       "      <td>289</td>\n",
       "      <td>2.911111</td>\n",
       "      <td>6</td>\n",
       "      <td>0.088889</td>\n",
       "      <td>1</td>\n",
       "      <td>0.133333</td>\n",
       "      <td>1</td>\n",
       "      <td>0.044444</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.608657</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.717821</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.692537</td>\n",
       "      <td>7</td>\n",
       "      <td>202.456716</td>\n",
       "      <td>310</td>\n",
       "      <td>3.259701</td>\n",
       "      <td>6</td>\n",
       "      <td>0.137313</td>\n",
       "      <td>1</td>\n",
       "      <td>0.274627</td>\n",
       "      <td>1</td>\n",
       "      <td>0.005970</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.580306</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.696100</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.590529</td>\n",
       "      <td>7</td>\n",
       "      <td>193.863510</td>\n",
       "      <td>310</td>\n",
       "      <td>3.501393</td>\n",
       "      <td>8</td>\n",
       "      <td>0.108635</td>\n",
       "      <td>1</td>\n",
       "      <td>0.325905</td>\n",
       "      <td>1</td>\n",
       "      <td>0.030641</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">management</th>\n",
       "      <th>high</th>\n",
       "      <td>0.653333</td>\n",
       "      <td>0.98</td>\n",
       "      <td>0.715822</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.777778</td>\n",
       "      <td>6</td>\n",
       "      <td>200.248889</td>\n",
       "      <td>286</td>\n",
       "      <td>5.164444</td>\n",
       "      <td>10</td>\n",
       "      <td>0.160000</td>\n",
       "      <td>1</td>\n",
       "      <td>0.004444</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.610722</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.712833</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.777778</td>\n",
       "      <td>7</td>\n",
       "      <td>200.744444</td>\n",
       "      <td>307</td>\n",
       "      <td>3.411111</td>\n",
       "      <td>10</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>1</td>\n",
       "      <td>0.327778</td>\n",
       "      <td>1</td>\n",
       "      <td>0.038889</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.597867</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.741111</td>\n",
       "      <td>1.00</td>\n",
       "      <td>4.008889</td>\n",
       "      <td>7</td>\n",
       "      <td>202.653333</td>\n",
       "      <td>304</td>\n",
       "      <td>4.155556</td>\n",
       "      <td>10</td>\n",
       "      <td>0.164444</td>\n",
       "      <td>1</td>\n",
       "      <td>0.137778</td>\n",
       "      <td>1</td>\n",
       "      <td>0.075556</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">marketing</th>\n",
       "      <th>high</th>\n",
       "      <td>0.605250</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.663625</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.425000</td>\n",
       "      <td>6</td>\n",
       "      <td>185.575000</td>\n",
       "      <td>286</td>\n",
       "      <td>3.512500</td>\n",
       "      <td>10</td>\n",
       "      <td>0.162500</td>\n",
       "      <td>1</td>\n",
       "      <td>0.112500</td>\n",
       "      <td>1</td>\n",
       "      <td>0.062500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.602910</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.727587</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.751244</td>\n",
       "      <td>7</td>\n",
       "      <td>204.487562</td>\n",
       "      <td>310</td>\n",
       "      <td>3.527363</td>\n",
       "      <td>10</td>\n",
       "      <td>0.154229</td>\n",
       "      <td>1</td>\n",
       "      <td>0.313433</td>\n",
       "      <td>1</td>\n",
       "      <td>0.027363</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.638218</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.714495</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.675532</td>\n",
       "      <td>7</td>\n",
       "      <td>196.869681</td>\n",
       "      <td>300</td>\n",
       "      <td>3.627660</td>\n",
       "      <td>10</td>\n",
       "      <td>0.167553</td>\n",
       "      <td>1</td>\n",
       "      <td>0.180851</td>\n",
       "      <td>1</td>\n",
       "      <td>0.071809</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">product_mng</th>\n",
       "      <th>high</th>\n",
       "      <td>0.614118</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.665735</td>\n",
       "      <td>0.98</td>\n",
       "      <td>3.705882</td>\n",
       "      <td>6</td>\n",
       "      <td>194.632353</td>\n",
       "      <td>307</td>\n",
       "      <td>3.617647</td>\n",
       "      <td>10</td>\n",
       "      <td>0.191176</td>\n",
       "      <td>1</td>\n",
       "      <td>0.088235</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.620909</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.725831</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.824834</td>\n",
       "      <td>7</td>\n",
       "      <td>201.048780</td>\n",
       "      <td>310</td>\n",
       "      <td>3.434590</td>\n",
       "      <td>10</td>\n",
       "      <td>0.150776</td>\n",
       "      <td>1</td>\n",
       "      <td>0.232816</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.619112</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.710418</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.804178</td>\n",
       "      <td>7</td>\n",
       "      <td>199.637076</td>\n",
       "      <td>310</td>\n",
       "      <td>3.498695</td>\n",
       "      <td>10</td>\n",
       "      <td>0.133159</td>\n",
       "      <td>1</td>\n",
       "      <td>0.227154</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">sales</th>\n",
       "      <th>high</th>\n",
       "      <td>0.648959</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.699814</td>\n",
       "      <td>0.99</td>\n",
       "      <td>3.858736</td>\n",
       "      <td>7</td>\n",
       "      <td>201.178439</td>\n",
       "      <td>306</td>\n",
       "      <td>3.550186</td>\n",
       "      <td>10</td>\n",
       "      <td>0.137546</td>\n",
       "      <td>1</td>\n",
       "      <td>0.052045</td>\n",
       "      <td>1</td>\n",
       "      <td>0.044610</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.600838</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.709247</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.757980</td>\n",
       "      <td>7</td>\n",
       "      <td>200.363030</td>\n",
       "      <td>307</td>\n",
       "      <td>3.464030</td>\n",
       "      <td>10</td>\n",
       "      <td>0.126251</td>\n",
       "      <td>1</td>\n",
       "      <td>0.332063</td>\n",
       "      <td>1</td>\n",
       "      <td>0.009528</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.625327</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.711778</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.785553</td>\n",
       "      <td>7</td>\n",
       "      <td>201.520316</td>\n",
       "      <td>310</td>\n",
       "      <td>3.614560</td>\n",
       "      <td>10</td>\n",
       "      <td>0.160835</td>\n",
       "      <td>1</td>\n",
       "      <td>0.170993</td>\n",
       "      <td>1</td>\n",
       "      <td>0.038375</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">support</th>\n",
       "      <th>high</th>\n",
       "      <td>0.655035</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.714113</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.794326</td>\n",
       "      <td>6</td>\n",
       "      <td>203.985816</td>\n",
       "      <td>286</td>\n",
       "      <td>3.219858</td>\n",
       "      <td>10</td>\n",
       "      <td>0.219858</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056738</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.591710</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.719494</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.787086</td>\n",
       "      <td>7</td>\n",
       "      <td>198.900524</td>\n",
       "      <td>310</td>\n",
       "      <td>3.484293</td>\n",
       "      <td>10</td>\n",
       "      <td>0.151832</td>\n",
       "      <td>1</td>\n",
       "      <td>0.339442</td>\n",
       "      <td>1</td>\n",
       "      <td>0.006108</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.645149</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.728854</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.825902</td>\n",
       "      <td>7</td>\n",
       "      <td>202.535032</td>\n",
       "      <td>310</td>\n",
       "      <td>3.307856</td>\n",
       "      <td>10</td>\n",
       "      <td>0.148620</td>\n",
       "      <td>1</td>\n",
       "      <td>0.167728</td>\n",
       "      <td>1</td>\n",
       "      <td>0.013800</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">technical</th>\n",
       "      <th>high</th>\n",
       "      <td>0.625970</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.699453</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.651741</td>\n",
       "      <td>6</td>\n",
       "      <td>200.044776</td>\n",
       "      <td>284</td>\n",
       "      <td>3.313433</td>\n",
       "      <td>10</td>\n",
       "      <td>0.149254</td>\n",
       "      <td>1</td>\n",
       "      <td>0.124378</td>\n",
       "      <td>1</td>\n",
       "      <td>0.004975</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>0.594322</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.723367</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.910350</td>\n",
       "      <td>7</td>\n",
       "      <td>203.064869</td>\n",
       "      <td>310</td>\n",
       "      <td>3.397230</td>\n",
       "      <td>10</td>\n",
       "      <td>0.142128</td>\n",
       "      <td>1</td>\n",
       "      <td>0.275510</td>\n",
       "      <td>1</td>\n",
       "      <td>0.008746</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>0.620968</td>\n",
       "      <td>1.00</td>\n",
       "      <td>0.722180</td>\n",
       "      <td>1.00</td>\n",
       "      <td>3.878814</td>\n",
       "      <td>7</td>\n",
       "      <td>202.248474</td>\n",
       "      <td>310</td>\n",
       "      <td>3.445510</td>\n",
       "      <td>10</td>\n",
       "      <td>0.136007</td>\n",
       "      <td>1</td>\n",
       "      <td>0.256321</td>\n",
       "      <td>1</td>\n",
       "      <td>0.013078</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   satisfaction_level       last_evaluation        \\\n",
       "                                 mean  amax            mean  amax   \n",
       "department  salary                                                  \n",
       "IT          high             0.638193  0.99        0.716627  0.99   \n",
       "            low              0.610099  1.00        0.715665  1.00   \n",
       "            medium           0.624187  1.00        0.718187  1.00   \n",
       "RandD       high             0.586667  0.97        0.700588  0.95   \n",
       "            low              0.623929  1.00        0.714176  1.00   \n",
       "            medium           0.620349  1.00        0.711694  1.00   \n",
       "accounting  high             0.614054  0.97        0.724595  1.00   \n",
       "            low              0.574162  1.00        0.713883  1.00   \n",
       "            medium           0.583642  1.00        0.720299  1.00   \n",
       "hr          high             0.673111  0.99        0.743778  0.99   \n",
       "            low              0.608657  1.00        0.717821  1.00   \n",
       "            medium           0.580306  1.00        0.696100  1.00   \n",
       "management  high             0.653333  0.98        0.715822  1.00   \n",
       "            low              0.610722  1.00        0.712833  1.00   \n",
       "            medium           0.597867  1.00        0.741111  1.00   \n",
       "marketing   high             0.605250  1.00        0.663625  1.00   \n",
       "            low              0.602910  0.99        0.727587  1.00   \n",
       "            medium           0.638218  1.00        0.714495  1.00   \n",
       "product_mng high             0.614118  0.99        0.665735  0.98   \n",
       "            low              0.620909  1.00        0.725831  1.00   \n",
       "            medium           0.619112  1.00        0.710418  1.00   \n",
       "sales       high             0.648959  1.00        0.699814  0.99   \n",
       "            low              0.600838  1.00        0.709247  1.00   \n",
       "            medium           0.625327  1.00        0.711778  1.00   \n",
       "support     high             0.655035  0.99        0.714113  1.00   \n",
       "            low              0.591710  1.00        0.719494  1.00   \n",
       "            medium           0.645149  1.00        0.728854  1.00   \n",
       "technical   high             0.625970  1.00        0.699453  1.00   \n",
       "            low              0.594322  1.00        0.723367  1.00   \n",
       "            medium           0.620968  1.00        0.722180  1.00   \n",
       "\n",
       "                   number_project      average_montly_hours       \\\n",
       "                             mean amax                 mean amax   \n",
       "department  salary                                                 \n",
       "IT          high         3.867470    6           194.927711  275   \n",
       "            low          3.794745    7           201.382594  308   \n",
       "            medium       3.833645    7           204.295327  308   \n",
       "RandD       high         3.764706    6           199.745098  287   \n",
       "            low          3.804945    7           198.747253  308   \n",
       "            medium       3.913978    7           202.954301  301   \n",
       "accounting  high         3.905405    6           205.905405  277   \n",
       "            low          3.801676    7           199.899441  308   \n",
       "            medium       3.832836    7           201.465672  310   \n",
       "hr          high         3.888889    6           209.066667  289   \n",
       "            low          3.692537    7           202.456716  310   \n",
       "            medium       3.590529    7           193.863510  310   \n",
       "management  high         3.777778    6           200.248889  286   \n",
       "            low          3.777778    7           200.744444  307   \n",
       "            medium       4.008889    7           202.653333  304   \n",
       "marketing   high         3.425000    6           185.575000  286   \n",
       "            low          3.751244    7           204.487562  310   \n",
       "            medium       3.675532    7           196.869681  300   \n",
       "product_mng high         3.705882    6           194.632353  307   \n",
       "            low          3.824834    7           201.048780  310   \n",
       "            medium       3.804178    7           199.637076  310   \n",
       "sales       high         3.858736    7           201.178439  306   \n",
       "            low          3.757980    7           200.363030  307   \n",
       "            medium       3.785553    7           201.520316  310   \n",
       "support     high         3.794326    6           203.985816  286   \n",
       "            low          3.787086    7           198.900524  310   \n",
       "            medium       3.825902    7           202.535032  310   \n",
       "technical   high         3.651741    6           200.044776  284   \n",
       "            low          3.910350    7           203.064869  310   \n",
       "            medium       3.878814    7           202.248474  310   \n",
       "\n",
       "                   time_spend_company      Work_accident           left       \\\n",
       "                                 mean amax          mean amax      mean amax   \n",
       "department  salary                                                             \n",
       "IT          high             3.072289    6      0.048193    1  0.048193    1   \n",
       "            low              3.438424   10      0.146141    1  0.282430    1   \n",
       "            medium           3.564486   10      0.132710    1  0.181308    1   \n",
       "RandD       high             3.529412    8      0.176471    1  0.078431    1   \n",
       "            low              3.381868    8      0.195055    1  0.151099    1   \n",
       "            medium           3.330645    6      0.145161    1  0.166667    1   \n",
       "accounting  high             3.216216    8      0.202703    1  0.067568    1   \n",
       "            low              3.438547   10      0.111732    1  0.276536    1   \n",
       "            medium           3.680597   10      0.122388    1  0.298507    1   \n",
       "hr          high             2.911111    6      0.088889    1  0.133333    1   \n",
       "            low              3.259701    6      0.137313    1  0.274627    1   \n",
       "            medium           3.501393    8      0.108635    1  0.325905    1   \n",
       "management  high             5.164444   10      0.160000    1  0.004444    1   \n",
       "            low              3.411111   10      0.166667    1  0.327778    1   \n",
       "            medium           4.155556   10      0.164444    1  0.137778    1   \n",
       "marketing   high             3.512500   10      0.162500    1  0.112500    1   \n",
       "            low              3.527363   10      0.154229    1  0.313433    1   \n",
       "            medium           3.627660   10      0.167553    1  0.180851    1   \n",
       "product_mng high             3.617647   10      0.191176    1  0.088235    1   \n",
       "            low              3.434590   10      0.150776    1  0.232816    1   \n",
       "            medium           3.498695   10      0.133159    1  0.227154    1   \n",
       "sales       high             3.550186   10      0.137546    1  0.052045    1   \n",
       "            low              3.464030   10      0.126251    1  0.332063    1   \n",
       "            medium           3.614560   10      0.160835    1  0.170993    1   \n",
       "support     high             3.219858   10      0.219858    1  0.056738    1   \n",
       "            low              3.484293   10      0.151832    1  0.339442    1   \n",
       "            medium           3.307856   10      0.148620    1  0.167728    1   \n",
       "technical   high             3.313433   10      0.149254    1  0.124378    1   \n",
       "            low              3.397230   10      0.142128    1  0.275510    1   \n",
       "            medium           3.445510   10      0.136007    1  0.256321    1   \n",
       "\n",
       "                   promotion_last_5years       \n",
       "                                    mean amax  \n",
       "department  salary                             \n",
       "IT          high                0.000000    0  \n",
       "            low                 0.003284    1  \n",
       "            medium              0.001869    1  \n",
       "RandD       high                0.019608    1  \n",
       "            low                 0.008242    1  \n",
       "            medium              0.061828    1  \n",
       "accounting  high                0.081081    1  \n",
       "            low                 0.005587    1  \n",
       "            medium              0.017910    1  \n",
       "hr          high                0.044444    1  \n",
       "            low                 0.005970    1  \n",
       "            medium              0.030641    1  \n",
       "management  high                0.200000    1  \n",
       "            low                 0.038889    1  \n",
       "            medium              0.075556    1  \n",
       "marketing   high                0.062500    1  \n",
       "            low                 0.027363    1  \n",
       "            medium              0.071809    1  \n",
       "product_mng high                0.000000    0  \n",
       "            low                 0.000000    0  \n",
       "            medium              0.000000    0  \n",
       "sales       high                0.044610    1  \n",
       "            low                 0.009528    1  \n",
       "            medium              0.038375    1  \n",
       "support     high                0.000000    0  \n",
       "            low                 0.006108    1  \n",
       "            medium              0.013800    1  \n",
       "technical   high                0.004975    1  \n",
       "            low                 0.008746    1  \n",
       "            medium              0.013078    1  "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.agg([np.mean,np.max])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Descriptive statistics of grouped data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "department   salary\n",
       "IT           high        83\n",
       "             low        609\n",
       "             medium     535\n",
       "RandD        high        51\n",
       "             low        364\n",
       "             medium     372\n",
       "accounting   high        74\n",
       "             low        358\n",
       "             medium     335\n",
       "hr           high        45\n",
       "             low        335\n",
       "             medium     359\n",
       "management   high       225\n",
       "             low        180\n",
       "             medium     225\n",
       "marketing    high        80\n",
       "             low        402\n",
       "             medium     376\n",
       "product_mng  high        68\n",
       "             low        451\n",
       "             medium     383\n",
       "sales        high       269\n",
       "             low       2099\n",
       "             medium    1772\n",
       "support      high       141\n",
       "             low       1146\n",
       "             medium     942\n",
       "technical    high       201\n",
       "             low       1372\n",
       "             medium    1147\n",
       "dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th colspan=\"8\" halign=\"left\">satisfaction_level</th>\n",
       "      <th colspan=\"2\" halign=\"left\">last_evaluation</th>\n",
       "      <th>...</th>\n",
       "      <th colspan=\"2\" halign=\"left\">left</th>\n",
       "      <th colspan=\"8\" halign=\"left\">promotion_last_5years</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>...</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>department</th>\n",
       "      <th>salary</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">IT</th>\n",
       "      <th>high</th>\n",
       "      <td>83.0</td>\n",
       "      <td>0.638193</td>\n",
       "      <td>0.223749</td>\n",
       "      <td>0.15</td>\n",
       "      <td>0.5250</td>\n",
       "      <td>0.650</td>\n",
       "      <td>0.7800</td>\n",
       "      <td>0.99</td>\n",
       "      <td>83.0</td>\n",
       "      <td>0.716627</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>83.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>609.0</td>\n",
       "      <td>0.610099</td>\n",
       "      <td>0.258915</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4100</td>\n",
       "      <td>0.650</td>\n",
       "      <td>0.8200</td>\n",
       "      <td>1.00</td>\n",
       "      <td>609.0</td>\n",
       "      <td>0.715665</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>609.0</td>\n",
       "      <td>0.003284</td>\n",
       "      <td>0.057260</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>535.0</td>\n",
       "      <td>0.624187</td>\n",
       "      <td>0.243297</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4900</td>\n",
       "      <td>0.660</td>\n",
       "      <td>0.8100</td>\n",
       "      <td>1.00</td>\n",
       "      <td>535.0</td>\n",
       "      <td>0.718187</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>535.0</td>\n",
       "      <td>0.001869</td>\n",
       "      <td>0.043234</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">RandD</th>\n",
       "      <th>high</th>\n",
       "      <td>51.0</td>\n",
       "      <td>0.586667</td>\n",
       "      <td>0.228785</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.4400</td>\n",
       "      <td>0.600</td>\n",
       "      <td>0.7450</td>\n",
       "      <td>0.97</td>\n",
       "      <td>51.0</td>\n",
       "      <td>0.700588</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>51.0</td>\n",
       "      <td>0.019608</td>\n",
       "      <td>0.140028</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>364.0</td>\n",
       "      <td>0.623929</td>\n",
       "      <td>0.242586</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4700</td>\n",
       "      <td>0.675</td>\n",
       "      <td>0.8200</td>\n",
       "      <td>1.00</td>\n",
       "      <td>364.0</td>\n",
       "      <td>0.714176</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>364.0</td>\n",
       "      <td>0.008242</td>\n",
       "      <td>0.090534</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>372.0</td>\n",
       "      <td>0.620349</td>\n",
       "      <td>0.250293</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4775</td>\n",
       "      <td>0.650</td>\n",
       "      <td>0.8300</td>\n",
       "      <td>1.00</td>\n",
       "      <td>372.0</td>\n",
       "      <td>0.711694</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>372.0</td>\n",
       "      <td>0.061828</td>\n",
       "      <td>0.241167</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">accounting</th>\n",
       "      <th>high</th>\n",
       "      <td>74.0</td>\n",
       "      <td>0.614054</td>\n",
       "      <td>0.237319</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.5000</td>\n",
       "      <td>0.620</td>\n",
       "      <td>0.8300</td>\n",
       "      <td>0.97</td>\n",
       "      <td>74.0</td>\n",
       "      <td>0.724595</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>74.0</td>\n",
       "      <td>0.081081</td>\n",
       "      <td>0.274823</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>358.0</td>\n",
       "      <td>0.574162</td>\n",
       "      <td>0.252250</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4000</td>\n",
       "      <td>0.590</td>\n",
       "      <td>0.7800</td>\n",
       "      <td>1.00</td>\n",
       "      <td>358.0</td>\n",
       "      <td>0.713883</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>358.0</td>\n",
       "      <td>0.005587</td>\n",
       "      <td>0.074639</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>335.0</td>\n",
       "      <td>0.583642</td>\n",
       "      <td>0.262273</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4000</td>\n",
       "      <td>0.630</td>\n",
       "      <td>0.8000</td>\n",
       "      <td>1.00</td>\n",
       "      <td>335.0</td>\n",
       "      <td>0.720299</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>335.0</td>\n",
       "      <td>0.017910</td>\n",
       "      <td>0.132824</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">hr</th>\n",
       "      <th>high</th>\n",
       "      <td>45.0</td>\n",
       "      <td>0.673111</td>\n",
       "      <td>0.250616</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.5500</td>\n",
       "      <td>0.730</td>\n",
       "      <td>0.8600</td>\n",
       "      <td>0.99</td>\n",
       "      <td>45.0</td>\n",
       "      <td>0.743778</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>45.0</td>\n",
       "      <td>0.044444</td>\n",
       "      <td>0.208409</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>335.0</td>\n",
       "      <td>0.608657</td>\n",
       "      <td>0.239902</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4400</td>\n",
       "      <td>0.620</td>\n",
       "      <td>0.8100</td>\n",
       "      <td>1.00</td>\n",
       "      <td>335.0</td>\n",
       "      <td>0.717821</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>335.0</td>\n",
       "      <td>0.005970</td>\n",
       "      <td>0.077151</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>359.0</td>\n",
       "      <td>0.580306</td>\n",
       "      <td>0.253324</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4050</td>\n",
       "      <td>0.600</td>\n",
       "      <td>0.7950</td>\n",
       "      <td>1.00</td>\n",
       "      <td>359.0</td>\n",
       "      <td>0.696100</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>359.0</td>\n",
       "      <td>0.030641</td>\n",
       "      <td>0.172583</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">management</th>\n",
       "      <th>high</th>\n",
       "      <td>225.0</td>\n",
       "      <td>0.653333</td>\n",
       "      <td>0.194436</td>\n",
       "      <td>0.14</td>\n",
       "      <td>0.5300</td>\n",
       "      <td>0.680</td>\n",
       "      <td>0.8000</td>\n",
       "      <td>0.98</td>\n",
       "      <td>225.0</td>\n",
       "      <td>0.715822</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>225.0</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.400892</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>180.0</td>\n",
       "      <td>0.610722</td>\n",
       "      <td>0.254620</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4350</td>\n",
       "      <td>0.655</td>\n",
       "      <td>0.8050</td>\n",
       "      <td>1.00</td>\n",
       "      <td>180.0</td>\n",
       "      <td>0.712833</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>180.0</td>\n",
       "      <td>0.038889</td>\n",
       "      <td>0.193869</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>225.0</td>\n",
       "      <td>0.597867</td>\n",
       "      <td>0.233161</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4800</td>\n",
       "      <td>0.630</td>\n",
       "      <td>0.7600</td>\n",
       "      <td>1.00</td>\n",
       "      <td>225.0</td>\n",
       "      <td>0.741111</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>225.0</td>\n",
       "      <td>0.075556</td>\n",
       "      <td>0.264875</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">marketing</th>\n",
       "      <th>high</th>\n",
       "      <td>80.0</td>\n",
       "      <td>0.605250</td>\n",
       "      <td>0.255784</td>\n",
       "      <td>0.14</td>\n",
       "      <td>0.4350</td>\n",
       "      <td>0.610</td>\n",
       "      <td>0.8275</td>\n",
       "      <td>1.00</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.663625</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.062500</td>\n",
       "      <td>0.243589</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>402.0</td>\n",
       "      <td>0.602910</td>\n",
       "      <td>0.256258</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4200</td>\n",
       "      <td>0.630</td>\n",
       "      <td>0.8100</td>\n",
       "      <td>0.99</td>\n",
       "      <td>402.0</td>\n",
       "      <td>0.727587</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>402.0</td>\n",
       "      <td>0.027363</td>\n",
       "      <td>0.163343</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>376.0</td>\n",
       "      <td>0.638218</td>\n",
       "      <td>0.227333</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4900</td>\n",
       "      <td>0.670</td>\n",
       "      <td>0.8200</td>\n",
       "      <td>1.00</td>\n",
       "      <td>376.0</td>\n",
       "      <td>0.714495</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>376.0</td>\n",
       "      <td>0.071809</td>\n",
       "      <td>0.258515</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">product_mng</th>\n",
       "      <th>high</th>\n",
       "      <td>68.0</td>\n",
       "      <td>0.614118</td>\n",
       "      <td>0.248038</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4500</td>\n",
       "      <td>0.625</td>\n",
       "      <td>0.8225</td>\n",
       "      <td>0.99</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.665735</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>451.0</td>\n",
       "      <td>0.620909</td>\n",
       "      <td>0.248181</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4450</td>\n",
       "      <td>0.650</td>\n",
       "      <td>0.8300</td>\n",
       "      <td>1.00</td>\n",
       "      <td>451.0</td>\n",
       "      <td>0.725831</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>451.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>383.0</td>\n",
       "      <td>0.619112</td>\n",
       "      <td>0.234720</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4500</td>\n",
       "      <td>0.640</td>\n",
       "      <td>0.8100</td>\n",
       "      <td>1.00</td>\n",
       "      <td>383.0</td>\n",
       "      <td>0.710418</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>383.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">sales</th>\n",
       "      <th>high</th>\n",
       "      <td>269.0</td>\n",
       "      <td>0.648959</td>\n",
       "      <td>0.236264</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.5200</td>\n",
       "      <td>0.690</td>\n",
       "      <td>0.8200</td>\n",
       "      <td>1.00</td>\n",
       "      <td>269.0</td>\n",
       "      <td>0.699814</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>269.0</td>\n",
       "      <td>0.044610</td>\n",
       "      <td>0.206830</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>2099.0</td>\n",
       "      <td>0.600838</td>\n",
       "      <td>0.251686</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4200</td>\n",
       "      <td>0.630</td>\n",
       "      <td>0.8100</td>\n",
       "      <td>1.00</td>\n",
       "      <td>2099.0</td>\n",
       "      <td>0.709247</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2099.0</td>\n",
       "      <td>0.009528</td>\n",
       "      <td>0.097170</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>1772.0</td>\n",
       "      <td>0.625327</td>\n",
       "      <td>0.249707</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4500</td>\n",
       "      <td>0.660</td>\n",
       "      <td>0.8300</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1772.0</td>\n",
       "      <td>0.711778</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1772.0</td>\n",
       "      <td>0.038375</td>\n",
       "      <td>0.192153</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">support</th>\n",
       "      <th>high</th>\n",
       "      <td>141.0</td>\n",
       "      <td>0.655035</td>\n",
       "      <td>0.225644</td>\n",
       "      <td>0.15</td>\n",
       "      <td>0.5100</td>\n",
       "      <td>0.670</td>\n",
       "      <td>0.8600</td>\n",
       "      <td>0.99</td>\n",
       "      <td>141.0</td>\n",
       "      <td>0.714113</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>141.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>1146.0</td>\n",
       "      <td>0.591710</td>\n",
       "      <td>0.255661</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4000</td>\n",
       "      <td>0.630</td>\n",
       "      <td>0.8000</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1146.0</td>\n",
       "      <td>0.719494</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1146.0</td>\n",
       "      <td>0.006108</td>\n",
       "      <td>0.077950</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>942.0</td>\n",
       "      <td>0.645149</td>\n",
       "      <td>0.234231</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.5100</td>\n",
       "      <td>0.680</td>\n",
       "      <td>0.8300</td>\n",
       "      <td>1.00</td>\n",
       "      <td>942.0</td>\n",
       "      <td>0.728854</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>942.0</td>\n",
       "      <td>0.013800</td>\n",
       "      <td>0.116724</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">technical</th>\n",
       "      <th>high</th>\n",
       "      <td>201.0</td>\n",
       "      <td>0.625970</td>\n",
       "      <td>0.219279</td>\n",
       "      <td>0.10</td>\n",
       "      <td>0.4900</td>\n",
       "      <td>0.640</td>\n",
       "      <td>0.7900</td>\n",
       "      <td>1.00</td>\n",
       "      <td>201.0</td>\n",
       "      <td>0.699453</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>201.0</td>\n",
       "      <td>0.004975</td>\n",
       "      <td>0.070535</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>1372.0</td>\n",
       "      <td>0.594322</td>\n",
       "      <td>0.264359</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4100</td>\n",
       "      <td>0.630</td>\n",
       "      <td>0.8200</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1372.0</td>\n",
       "      <td>0.723367</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1372.0</td>\n",
       "      <td>0.008746</td>\n",
       "      <td>0.093146</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>medium</th>\n",
       "      <td>1147.0</td>\n",
       "      <td>0.620968</td>\n",
       "      <td>0.246691</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.4500</td>\n",
       "      <td>0.660</td>\n",
       "      <td>0.8300</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1147.0</td>\n",
       "      <td>0.722180</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1147.0</td>\n",
       "      <td>0.013078</td>\n",
       "      <td>0.113657</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>30 rows × 64 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                   satisfaction_level                                    \\\n",
       "                                count      mean       std   min     25%   \n",
       "department  salary                                                        \n",
       "IT          high                 83.0  0.638193  0.223749  0.15  0.5250   \n",
       "            low                 609.0  0.610099  0.258915  0.09  0.4100   \n",
       "            medium              535.0  0.624187  0.243297  0.09  0.4900   \n",
       "RandD       high                 51.0  0.586667  0.228785  0.10  0.4400   \n",
       "            low                 364.0  0.623929  0.242586  0.09  0.4700   \n",
       "            medium              372.0  0.620349  0.250293  0.09  0.4775   \n",
       "accounting  high                 74.0  0.614054  0.237319  0.11  0.5000   \n",
       "            low                 358.0  0.574162  0.252250  0.09  0.4000   \n",
       "            medium              335.0  0.583642  0.262273  0.09  0.4000   \n",
       "hr          high                 45.0  0.673111  0.250616  0.09  0.5500   \n",
       "            low                 335.0  0.608657  0.239902  0.09  0.4400   \n",
       "            medium              359.0  0.580306  0.253324  0.09  0.4050   \n",
       "management  high                225.0  0.653333  0.194436  0.14  0.5300   \n",
       "            low                 180.0  0.610722  0.254620  0.09  0.4350   \n",
       "            medium              225.0  0.597867  0.233161  0.09  0.4800   \n",
       "marketing   high                 80.0  0.605250  0.255784  0.14  0.4350   \n",
       "            low                 402.0  0.602910  0.256258  0.09  0.4200   \n",
       "            medium              376.0  0.638218  0.227333  0.09  0.4900   \n",
       "product_mng high                 68.0  0.614118  0.248038  0.09  0.4500   \n",
       "            low                 451.0  0.620909  0.248181  0.09  0.4450   \n",
       "            medium              383.0  0.619112  0.234720  0.09  0.4500   \n",
       "sales       high                269.0  0.648959  0.236264  0.10  0.5200   \n",
       "            low                2099.0  0.600838  0.251686  0.09  0.4200   \n",
       "            medium             1772.0  0.625327  0.249707  0.09  0.4500   \n",
       "support     high                141.0  0.655035  0.225644  0.15  0.5100   \n",
       "            low                1146.0  0.591710  0.255661  0.09  0.4000   \n",
       "            medium              942.0  0.645149  0.234231  0.09  0.5100   \n",
       "technical   high                201.0  0.625970  0.219279  0.10  0.4900   \n",
       "            low                1372.0  0.594322  0.264359  0.09  0.4100   \n",
       "            medium             1147.0  0.620968  0.246691  0.09  0.4500   \n",
       "\n",
       "                                        last_evaluation            ... left  \\\n",
       "                      50%     75%   max           count      mean  ...  75%   \n",
       "department  salary                                                 ...        \n",
       "IT          high    0.650  0.7800  0.99            83.0  0.716627  ...  0.0   \n",
       "            low     0.650  0.8200  1.00           609.0  0.715665  ...  1.0   \n",
       "            medium  0.660  0.8100  1.00           535.0  0.718187  ...  0.0   \n",
       "RandD       high    0.600  0.7450  0.97            51.0  0.700588  ...  0.0   \n",
       "            low     0.675  0.8200  1.00           364.0  0.714176  ...  0.0   \n",
       "            medium  0.650  0.8300  1.00           372.0  0.711694  ...  0.0   \n",
       "accounting  high    0.620  0.8300  0.97            74.0  0.724595  ...  0.0   \n",
       "            low     0.590  0.7800  1.00           358.0  0.713883  ...  1.0   \n",
       "            medium  0.630  0.8000  1.00           335.0  0.720299  ...  1.0   \n",
       "hr          high    0.730  0.8600  0.99            45.0  0.743778  ...  0.0   \n",
       "            low     0.620  0.8100  1.00           335.0  0.717821  ...  1.0   \n",
       "            medium  0.600  0.7950  1.00           359.0  0.696100  ...  1.0   \n",
       "management  high    0.680  0.8000  0.98           225.0  0.715822  ...  0.0   \n",
       "            low     0.655  0.8050  1.00           180.0  0.712833  ...  1.0   \n",
       "            medium  0.630  0.7600  1.00           225.0  0.741111  ...  0.0   \n",
       "marketing   high    0.610  0.8275  1.00            80.0  0.663625  ...  0.0   \n",
       "            low     0.630  0.8100  0.99           402.0  0.727587  ...  1.0   \n",
       "            medium  0.670  0.8200  1.00           376.0  0.714495  ...  0.0   \n",
       "product_mng high    0.625  0.8225  0.99            68.0  0.665735  ...  0.0   \n",
       "            low     0.650  0.8300  1.00           451.0  0.725831  ...  0.0   \n",
       "            medium  0.640  0.8100  1.00           383.0  0.710418  ...  0.0   \n",
       "sales       high    0.690  0.8200  1.00           269.0  0.699814  ...  0.0   \n",
       "            low     0.630  0.8100  1.00          2099.0  0.709247  ...  1.0   \n",
       "            medium  0.660  0.8300  1.00          1772.0  0.711778  ...  0.0   \n",
       "support     high    0.670  0.8600  0.99           141.0  0.714113  ...  0.0   \n",
       "            low     0.630  0.8000  1.00          1146.0  0.719494  ...  1.0   \n",
       "            medium  0.680  0.8300  1.00           942.0  0.728854  ...  0.0   \n",
       "technical   high    0.640  0.7900  1.00           201.0  0.699453  ...  0.0   \n",
       "            low     0.630  0.8200  1.00          1372.0  0.723367  ...  1.0   \n",
       "            medium  0.660  0.8300  1.00          1147.0  0.722180  ...  1.0   \n",
       "\n",
       "                        promotion_last_5years                                \\\n",
       "                    max                 count      mean       std  min  25%   \n",
       "department  salary                                                            \n",
       "IT          high    1.0                  83.0  0.000000  0.000000  0.0  0.0   \n",
       "            low     1.0                 609.0  0.003284  0.057260  0.0  0.0   \n",
       "            medium  1.0                 535.0  0.001869  0.043234  0.0  0.0   \n",
       "RandD       high    1.0                  51.0  0.019608  0.140028  0.0  0.0   \n",
       "            low     1.0                 364.0  0.008242  0.090534  0.0  0.0   \n",
       "            medium  1.0                 372.0  0.061828  0.241167  0.0  0.0   \n",
       "accounting  high    1.0                  74.0  0.081081  0.274823  0.0  0.0   \n",
       "            low     1.0                 358.0  0.005587  0.074639  0.0  0.0   \n",
       "            medium  1.0                 335.0  0.017910  0.132824  0.0  0.0   \n",
       "hr          high    1.0                  45.0  0.044444  0.208409  0.0  0.0   \n",
       "            low     1.0                 335.0  0.005970  0.077151  0.0  0.0   \n",
       "            medium  1.0                 359.0  0.030641  0.172583  0.0  0.0   \n",
       "management  high    1.0                 225.0  0.200000  0.400892  0.0  0.0   \n",
       "            low     1.0                 180.0  0.038889  0.193869  0.0  0.0   \n",
       "            medium  1.0                 225.0  0.075556  0.264875  0.0  0.0   \n",
       "marketing   high    1.0                  80.0  0.062500  0.243589  0.0  0.0   \n",
       "            low     1.0                 402.0  0.027363  0.163343  0.0  0.0   \n",
       "            medium  1.0                 376.0  0.071809  0.258515  0.0  0.0   \n",
       "product_mng high    1.0                  68.0  0.000000  0.000000  0.0  0.0   \n",
       "            low     1.0                 451.0  0.000000  0.000000  0.0  0.0   \n",
       "            medium  1.0                 383.0  0.000000  0.000000  0.0  0.0   \n",
       "sales       high    1.0                 269.0  0.044610  0.206830  0.0  0.0   \n",
       "            low     1.0                2099.0  0.009528  0.097170  0.0  0.0   \n",
       "            medium  1.0                1772.0  0.038375  0.192153  0.0  0.0   \n",
       "support     high    1.0                 141.0  0.000000  0.000000  0.0  0.0   \n",
       "            low     1.0                1146.0  0.006108  0.077950  0.0  0.0   \n",
       "            medium  1.0                 942.0  0.013800  0.116724  0.0  0.0   \n",
       "technical   high    1.0                 201.0  0.004975  0.070535  0.0  0.0   \n",
       "            low     1.0                1372.0  0.008746  0.093146  0.0  0.0   \n",
       "            medium  1.0                1147.0  0.013078  0.113657  0.0  0.0   \n",
       "\n",
       "                                   \n",
       "                    50%  75%  max  \n",
       "department  salary                 \n",
       "IT          high    0.0  0.0  0.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "RandD       high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "accounting  high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "hr          high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "management  high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "marketing   high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "product_mng high    0.0  0.0  0.0  \n",
       "            low     0.0  0.0  0.0  \n",
       "            medium  0.0  0.0  0.0  \n",
       "sales       high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "support     high    0.0  0.0  0.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "technical   high    0.0  0.0  1.0  \n",
       "            low     0.0  0.0  1.0  \n",
       "            medium  0.0  0.0  1.0  \n",
       "\n",
       "[30 rows x 64 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped = hr_data.groupby(['department'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean_projects</th>\n",
       "      <th>mean_satisfaction</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>department</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>IT</th>\n",
       "      <td>3.816626</td>\n",
       "      <td>0.618142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RandD</th>\n",
       "      <td>3.853875</td>\n",
       "      <td>0.619822</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>accounting</th>\n",
       "      <td>3.825293</td>\n",
       "      <td>0.582151</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hr</th>\n",
       "      <td>3.654939</td>\n",
       "      <td>0.598809</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>management</th>\n",
       "      <td>3.860317</td>\n",
       "      <td>0.621349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>marketing</th>\n",
       "      <td>3.687646</td>\n",
       "      <td>0.618601</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>product_mng</th>\n",
       "      <td>3.807095</td>\n",
       "      <td>0.619634</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sales</th>\n",
       "      <td>3.776329</td>\n",
       "      <td>0.614447</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>support</th>\n",
       "      <td>3.803948</td>\n",
       "      <td>0.618300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>technical</th>\n",
       "      <td>3.877941</td>\n",
       "      <td>0.607897</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             mean_projects  mean_satisfaction\n",
       "department                                   \n",
       "IT                3.816626           0.618142\n",
       "RandD             3.853875           0.619822\n",
       "accounting        3.825293           0.582151\n",
       "hr                3.654939           0.598809\n",
       "management        3.860317           0.621349\n",
       "marketing         3.687646           0.618601\n",
       "product_mng       3.807095           0.619634\n",
       "sales             3.776329           0.614447\n",
       "support           3.803948           0.618300\n",
       "technical         3.877941           0.607897"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.agg(mean_projects=('number_project','mean'), mean_satisfaction=('satisfaction_level','mean'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>satisfaction_level</th>\n",
       "      <th>last_evaluation</th>\n",
       "      <th>number_project</th>\n",
       "      <th>average_montly_hours</th>\n",
       "      <th>time_spend_company</th>\n",
       "      <th>Work_accident</th>\n",
       "      <th>left</th>\n",
       "      <th>promotion_last_5years</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2.38</td>\n",
       "      <td>2.53</td>\n",
       "      <td>4</td>\n",
       "      <td>159</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2.80</td>\n",
       "      <td>2.86</td>\n",
       "      <td>7</td>\n",
       "      <td>264</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2.11</td>\n",
       "      <td>2.88</td>\n",
       "      <td>9</td>\n",
       "      <td>274</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.72</td>\n",
       "      <td>2.87</td>\n",
       "      <td>7</td>\n",
       "      <td>225</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2.37</td>\n",
       "      <td>2.52</td>\n",
       "      <td>4</td>\n",
       "      <td>161</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2.41</td>\n",
       "      <td>2.50</td>\n",
       "      <td>4</td>\n",
       "      <td>155</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2.10</td>\n",
       "      <td>2.77</td>\n",
       "      <td>8</td>\n",
       "      <td>249</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2.92</td>\n",
       "      <td>2.85</td>\n",
       "      <td>7</td>\n",
       "      <td>261</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2.89</td>\n",
       "      <td>3.00</td>\n",
       "      <td>7</td>\n",
       "      <td>226</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2.42</td>\n",
       "      <td>2.53</td>\n",
       "      <td>4</td>\n",
       "      <td>144</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2.45</td>\n",
       "      <td>2.54</td>\n",
       "      <td>4</td>\n",
       "      <td>137</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2.11</td>\n",
       "      <td>2.81</td>\n",
       "      <td>8</td>\n",
       "      <td>307</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2.84</td>\n",
       "      <td>2.92</td>\n",
       "      <td>6</td>\n",
       "      <td>236</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2.41</td>\n",
       "      <td>2.55</td>\n",
       "      <td>4</td>\n",
       "      <td>150</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2.36</td>\n",
       "      <td>2.56</td>\n",
       "      <td>4</td>\n",
       "      <td>139</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2.38</td>\n",
       "      <td>2.54</td>\n",
       "      <td>4</td>\n",
       "      <td>145</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2.45</td>\n",
       "      <td>2.47</td>\n",
       "      <td>4</td>\n",
       "      <td>162</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2.78</td>\n",
       "      <td>2.99</td>\n",
       "      <td>6</td>\n",
       "      <td>257</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2.45</td>\n",
       "      <td>2.51</td>\n",
       "      <td>4</td>\n",
       "      <td>162</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2.76</td>\n",
       "      <td>2.89</td>\n",
       "      <td>7</td>\n",
       "      <td>264</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2.11</td>\n",
       "      <td>2.83</td>\n",
       "      <td>8</td>\n",
       "      <td>284</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2.38</td>\n",
       "      <td>2.55</td>\n",
       "      <td>4</td>\n",
       "      <td>149</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2.09</td>\n",
       "      <td>2.95</td>\n",
       "      <td>8</td>\n",
       "      <td>306</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2.46</td>\n",
       "      <td>2.57</td>\n",
       "      <td>4</td>\n",
       "      <td>141</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.53</td>\n",
       "      <td>4</td>\n",
       "      <td>160</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2.89</td>\n",
       "      <td>2.92</td>\n",
       "      <td>7</td>\n",
       "      <td>244</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2.82</td>\n",
       "      <td>2.87</td>\n",
       "      <td>6</td>\n",
       "      <td>241</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.49</td>\n",
       "      <td>4</td>\n",
       "      <td>137</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2.41</td>\n",
       "      <td>2.46</td>\n",
       "      <td>4</td>\n",
       "      <td>130</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2.38</td>\n",
       "      <td>2.50</td>\n",
       "      <td>4</td>\n",
       "      <td>134</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14969</th>\n",
       "      <td>2.43</td>\n",
       "      <td>2.46</td>\n",
       "      <td>4</td>\n",
       "      <td>159</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14970</th>\n",
       "      <td>2.78</td>\n",
       "      <td>2.93</td>\n",
       "      <td>6</td>\n",
       "      <td>227</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14971</th>\n",
       "      <td>2.39</td>\n",
       "      <td>2.45</td>\n",
       "      <td>4</td>\n",
       "      <td>142</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14972</th>\n",
       "      <td>2.11</td>\n",
       "      <td>2.97</td>\n",
       "      <td>8</td>\n",
       "      <td>312</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14973</th>\n",
       "      <td>2.36</td>\n",
       "      <td>2.52</td>\n",
       "      <td>4</td>\n",
       "      <td>145</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14974</th>\n",
       "      <td>2.36</td>\n",
       "      <td>2.54</td>\n",
       "      <td>4</td>\n",
       "      <td>155</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14975</th>\n",
       "      <td>2.10</td>\n",
       "      <td>2.79</td>\n",
       "      <td>9</td>\n",
       "      <td>312</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14976</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.47</td>\n",
       "      <td>4</td>\n",
       "      <td>138</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14977</th>\n",
       "      <td>2.81</td>\n",
       "      <td>2.85</td>\n",
       "      <td>6</td>\n",
       "      <td>253</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14978</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.47</td>\n",
       "      <td>4</td>\n",
       "      <td>146</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14979</th>\n",
       "      <td>2.09</td>\n",
       "      <td>2.93</td>\n",
       "      <td>8</td>\n",
       "      <td>298</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14980</th>\n",
       "      <td>2.76</td>\n",
       "      <td>2.89</td>\n",
       "      <td>7</td>\n",
       "      <td>240</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14981</th>\n",
       "      <td>2.73</td>\n",
       "      <td>2.93</td>\n",
       "      <td>7</td>\n",
       "      <td>164</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14982</th>\n",
       "      <td>2.38</td>\n",
       "      <td>2.49</td>\n",
       "      <td>4</td>\n",
       "      <td>139</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14983</th>\n",
       "      <td>2.72</td>\n",
       "      <td>2.84</td>\n",
       "      <td>7</td>\n",
       "      <td>259</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14984</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.56</td>\n",
       "      <td>4</td>\n",
       "      <td>150</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14985</th>\n",
       "      <td>2.91</td>\n",
       "      <td>2.99</td>\n",
       "      <td>7</td>\n",
       "      <td>256</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14986</th>\n",
       "      <td>2.85</td>\n",
       "      <td>2.85</td>\n",
       "      <td>6</td>\n",
       "      <td>249</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14987</th>\n",
       "      <td>2.90</td>\n",
       "      <td>2.70</td>\n",
       "      <td>7</td>\n",
       "      <td>208</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14988</th>\n",
       "      <td>2.46</td>\n",
       "      <td>2.55</td>\n",
       "      <td>4</td>\n",
       "      <td>147</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14989</th>\n",
       "      <td>2.43</td>\n",
       "      <td>2.57</td>\n",
       "      <td>4</td>\n",
       "      <td>161</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14990</th>\n",
       "      <td>2.89</td>\n",
       "      <td>2.88</td>\n",
       "      <td>7</td>\n",
       "      <td>230</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14991</th>\n",
       "      <td>2.09</td>\n",
       "      <td>2.81</td>\n",
       "      <td>8</td>\n",
       "      <td>259</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14992</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.48</td>\n",
       "      <td>4</td>\n",
       "      <td>157</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14993</th>\n",
       "      <td>2.76</td>\n",
       "      <td>2.83</td>\n",
       "      <td>8</td>\n",
       "      <td>295</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14994</th>\n",
       "      <td>2.40</td>\n",
       "      <td>2.57</td>\n",
       "      <td>4</td>\n",
       "      <td>153</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14995</th>\n",
       "      <td>2.37</td>\n",
       "      <td>2.48</td>\n",
       "      <td>4</td>\n",
       "      <td>162</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14996</th>\n",
       "      <td>2.37</td>\n",
       "      <td>2.53</td>\n",
       "      <td>4</td>\n",
       "      <td>145</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14997</th>\n",
       "      <td>2.11</td>\n",
       "      <td>2.96</td>\n",
       "      <td>8</td>\n",
       "      <td>282</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14998</th>\n",
       "      <td>2.37</td>\n",
       "      <td>2.52</td>\n",
       "      <td>4</td>\n",
       "      <td>160</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>14999 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       satisfaction_level  last_evaluation  number_project  \\\n",
       "0                    2.38             2.53               4   \n",
       "1                    2.80             2.86               7   \n",
       "2                    2.11             2.88               9   \n",
       "3                    2.72             2.87               7   \n",
       "4                    2.37             2.52               4   \n",
       "...                   ...              ...             ...   \n",
       "14994                2.40             2.57               4   \n",
       "14995                2.37             2.48               4   \n",
       "14996                2.37             2.53               4   \n",
       "14997                2.11             2.96               8   \n",
       "14998                2.37             2.52               4   \n",
       "\n",
       "       average_montly_hours  time_spend_company  Work_accident  left  \\\n",
       "0                       159                   5              2     3   \n",
       "1                       264                   8              2     3   \n",
       "2                       274                   6              2     3   \n",
       "3                       225                   7              2     3   \n",
       "4                       161                   5              2     3   \n",
       "...                     ...                 ...            ...   ...   \n",
       "14994                   153                   5              2     3   \n",
       "14995                   162                   5              2     3   \n",
       "14996                   145                   5              2     3   \n",
       "14997                   282                   6              2     3   \n",
       "14998                   160                   5              2     3   \n",
       "\n",
       "       promotion_last_5years  \n",
       "0                          2  \n",
       "1                          2  \n",
       "2                          2  \n",
       "3                          2  \n",
       "4                          2  \n",
       "...                      ...  \n",
       "14994                      2  \n",
       "14995                      2  \n",
       "14996                      2  \n",
       "14997                      2  \n",
       "14998                      2  \n",
       "\n",
       "[14999 rows x 8 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.transform(lambda x : x + 2 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
